import { defineStore } from 'pinia'

export const useAppStore = defineStore('app-mobile', {
  state: () => ({
    dark: false,
    sidebarCollapsed: false, // 移动端侧边栏状态
    showBottomNav: true, // 移动端底部导航显示状态
  }),
  persist: {
    key: 'admin_mobile_app'
  },
  actions: {
    toggleDark(to?: boolean) {
      this.dark = typeof to === 'boolean' ? to : !this.dark
      if (this.dark) document.documentElement.classList.add('dark')
      else document.documentElement.classList.remove('dark')
    },
    toggleSidebar(to?: boolean) {
      this.sidebarCollapsed = typeof to === 'boolean' ? to : !this.sidebarCollapsed
    },
    toggleBottomNav(to?: boolean) {
      this.showBottomNav = typeof to === 'boolean' ? to : !this.showBottomNav
    },
  },
})
